import {createAction} from 'redux-actions';
import {
  ADD_TODO,
  TOGGLE_TODO,
  COMPLETE_TODO,
  REMOVE_TODO,
  SET_FILTER,
  FILTER_SHOW_ALL,
  FILTER_SHOW_COMPLETED,
  FILTER_SHOW_ACTIVE
} from '../../constants';

export const addTodo = createAction(ADD_TODO, text => ({text}));
export const removeTodo = createAction(REMOVE_TODO, index => ({index}));
export const toggleTodo = createAction(TOGGLE_TODO, index => ({index}));
export const completeTodo = createAction(COMPLETE_TODO, index => ({index}));

export const showAll = createAction(SET_FILTER, () => ({filter: FILTER_SHOW_ALL}));
export const showCompleted = createAction(SET_FILTER, () => ({filter: FILTER_SHOW_COMPLETED}));
export const showActive = createAction(SET_FILTER, () => ({filter: FILTER_SHOW_ACTIVE}));